<template>
  <div class="search-panel">
    <el-row class="m-header-searchbar">
      <el-col :span="6" class="left">
          <img src="//s0.meituan.net/bs/fe-web-meituan/fa5f0f0/img/logo.png" alt="美团外卖">
      </el-col>
      <el-col :span="12" class="center">
        <div class="wrapper">
          <el-input v-model="searchInput" @focus="focus" @blur="blur" placeholder="搜索商家或地点"></el-input>
          <button class="el-button el-button--primary">
            <i class="el-icon-search"></i>
          </button>
          <dl class="hotPlace" v-if="isHotPlace">
            <dt>热门搜索</dt>
            <dd v-for="(item, index) in hotPlace" :key="index">{{item}}</dd>
          </dl>
          <dl class="searchList" v-if="isSearchList">
           <dd v-for="(item, index) in searchList" :key="index">{{item}}</dd>
          </dl>
        </div>
        <p class="suggest">
          <a href="#">故宫博物院</a>
          <a href="#">故宫博物院</a>
          <a href="#">故宫博物院</a>
          <a href="#">故宫博物院</a>
          <a href="#">故宫博物院</a>
        </p>
        <ul class="nav">
            <li>
                <nuxt-link to="/wm" class="takeout">美团外卖</nuxt-link>
            </li>
            <li>
                <nuxt-link to="/movie" class="movie">猫眼电影</nuxt-link>
            </li>
            <li>
                <nuxt-link to="/hotel" class="hotel">美团酒店</nuxt-link>
            </li>
            <li>
                <nuxt-link to="/apartment" class="apartment">民宿/公寓</nuxt-link>
            </li>
             <li>
                <nuxt-link to="/business" class="business">商家入住</nuxt-link>
            </li>
        </ul>
      </el-col>
      <el-col :span="6" class="right">
        <ul class="security">
          <li>
            <i class="refund"></i>
            <p class="txt">随时退</p>
          </li>
          <li>
            <i class="overdue"></i>
            <p class="txt">过期退</p>
          </li>
          <li>
            <i class="single"></i>
            <p class="txt">不满意免单</p>
          </li>
        </ul>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
    data() {
        return {
            hotPlace: ['火锅', '酒店', '住宿'],
            searchList: ['天安门', '故宫', '水立方', '鸟巢'],
            isFocus: false,
            searchInput: ''
        }
    },
    computed: {
        isHotPlace() {
            return this.isFocus && !this.searchInput
        },
        isSearchList() {
            return this.isFocus && this.searchInput
        }
    },
    methods: {
        focus() {
            this.isFocus = true
        },
        blur() {
            const self = this
            setTimeout(() => {
                self.isFocus = false
            }, 200);
        }
    }
}
</script>
